package cn.tedu.api;

import java.util.Objects;

public class TestObject2 {
    public static void main(String[] args) {
    Cat c1=new Cat();
    Cat c2=new Cat();
    Cat c3=new Cat("机器猫",300,10000.99,"大雄",'男');
    Cat c4=new Cat("机器猫",300,10000.99,"大雄",'男');
    Dog d1=new Dog();
    Dog d2=new Dog();
    Dog d3=new Dog("旺财",5,500);
    Dog d4=new Dog("旺财",5,500);
        System.out.println(c1);
        System.out.println(d2);
        System.out.println(c3.equals(c4));
        System.out.println(d3.equals(d4));



    }
}
class Cat{
    String name;
    int age;
    double price;
    String host;
    char gender;
    public Cat() {
    }

    public Cat(String name, int age, double price, String host, char gender) {
        this.name = name;
        this.age = age;
        this.price = price;
        this.host = host;
        this.gender = gender;
    }

    /*@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cat cat = (Cat) o;
        return age == cat.age && Double.compare(cat.price, price) == 0 && gender == cat.gender && Objects.equals(name, cat.name) && Objects.equals(host, cat.host);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, price, host, gender);
    }*/
}
class Dog{
    String name;
    int age;
    double price;

    public Dog() {
    }

    public Dog(String name, int age, double price) {
        this.name = name;
        this.age = age;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", price=" + price +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Dog dog = (Dog) o;
        return age == dog.age && Double.compare(dog.price, price) == 0 && Objects.equals(name, dog.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, price);
    }
}